<?php

/**
 * ihelper_truncate_string
 * String truncate plugin for iwebform
 * @author Talha Buğra Bulut talhabulut@hotmail.com
 */
class ihelper_truncate_string {

    function truncate_string($string, $limit, $char='...') {
        $start = 0;
        $end = $limit;
        $str = strip_tags($string);
        $str = trim($str);
        preg_match_all("/./u", $str, $ar);
        if (strlen($str) > $end) {
            return join("", array_slice($ar[0], $start, $end)) . $char;
        } else {
            return join("", array_slice($ar[0], $start, $end));
        }
    }

}

?>